import React, {Component} from 'react'
import { Link } from 'react-router'
import './sm-extend.min.css'
import './sm.min.css'
import './index.css'
import Barnav from './barnav'
import $ from 'jquery'

class Logpage extends Component{
    constructor(){
        super();
    }
    handck(){
        let username = this.refs.username.value
        let password = this.refs.password.value
        let data={
            username:username,
            password:password,
        }
        $.post('http://127.0.0.1:8080/log',data,function(data,textStatus,xhr){
            if(String(data)=="success"){
                localStorage.setItem("name",username);
                window.location.href="http://127.0.0.1:3000/#/content"
            }else{
                alert('你输入的账号或者密码错误');
            }
        })
    }
    render(){
        return(
            <div>
            <Barnav/>
            <div className="content">
            <img src="../images/logo.png" className="logo" />
            <div className="list-block Logpage">
            <ul>

            <li>
            <div className="item-content">
            <div className="item-media"><i className="icon icon-form-name"></i></div>
            <div className="item-inner">
            <div className="item-title label greyfont">邮箱</div>
            <div className="item-input">
            <input type="text" placeholder="Your email" ref="username"/>
            </div>
            </div>
            </div>
            </li>
            <li>
            <div className="item-content">
            <div className="item-media"><i className="icon icon-form-email"></i></div>
            <div className="item-inner">
            <div className="item-title label greyfont">密码</div>
            <div className="item-input">
            <input type="password" placeholder="password" ref="password"/>
            </div>
            </div>
            </div>
            </li>
            </ul>
            </div>

            <div className="content-block">
            <div className="row">

            <div className="col-100"><a className="button button-big button-fill button-success" onClick={this.handck.bind(this)}>登录</a></div>
            </div>
            </div>
            </div>
            </div>
    )

    }

}


export default Logpage